<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>模板模块</title>
</head>
<body>
    <div id="template_list_head">
        <form class="form-inline">
            <div class="form-group">
                <label for="name">模板名称</label>
                <input type="text" class="form-control" id="name">
            </div>
            <div class="form-group">
                <label for="course">关联课程</label>
                <select  class="form-control" id="course">
                    <option>==请选择==</option>
                    <option th:each="course:${allCourse}" th:value="${course}" th:text="${course}"></option>
                </select>
            </div>
            <div class="form-group">
                <label for="type">模板类型</label>
                <select  class="form-control" id="type">
                    <option>==请选择==</option>
                    <option value="静态模板">静态模板</option>
                    <option value="动态模板">动态模板</option>
                </select>
            </div>
            <div class="form-group">
                <label for="status">模板状态</label>
                <select class="form-control" id="status">
                    <option>==请选择==</option>
                    <option value="公有">公有</option>
                    <option value="私有">私有</option>
                    <option value="被分享">被分享</option>
                    <option value="丢弃">丢弃</option>
                </select>
            </div>
            <div class="form-group">
                <label for="share">分享教师</label>
                <select  class="form-control" id="share">
                    <option>==请选择==</option>
                    <option th:each="teacher:${shareTeachers}" th:value="${teacher.id}" th:text="${teacher.tname}"></option>
                </select>
            </div>
            <button onclick="template.list.query()" type="button" class="btn btn-default"><span class="glyphicon glyphicon-zoom-in"></span>查询</button>
            <button onclick="template.list.clearQuery()" type="button" class="btn btn-default"><span class="glyphicon glyphicon-zoom-out"></span>清空查询</button>
        </form>
    </div>

    <div id="template_list_body">
        <th:block th:if="${examSymbol!=null}">
            <input type="hidden" id="exam_relation_template_symbol" th:value="${examSymbol}"/>
        </th:block>
        <table class="table table-hover">
            <thead>
                <tr>
                    <th><input type="checkbox"></th>
                    <th>序号</th>
                    <th>模板类型</th>
                    <th>模板名称</th>
                    <th>关联课程</th>
                    <th>总分</th>
                    <th>模板状态</th>
                    <th>所属老师</th>
                    <th>分享给</th>
                    <th>创建时间</th>
                    <th:block th:if="${examSymbol!=null || examSymbol!=''}"></th:block>
                    <th:block th:if="${examSymbol==null || examSymbol==''}">
                        <th>操作</th>
                    </th:block>
                </tr>
            </thead>
            <tbody>
                <th:block th:if="${pageVO.params==null || pageVO.params.size()==0}">
                    <tr>
                        <td colspan="11" align="center">没有任何查询记录</td>
                    </tr>
                </th:block>
                <th:block th:unless="${pageVO.params==null || pageVO.params.size()==0}">
                    <tr th:each="template:${pageVO.params}">
                        <td><input th:value="${template.id}" type="checkbox"/></td>
                        <td th:text="${templateStat.index+1}"></td>
                        <td>
                            <span class="label label-primary" th:if="${template.templateType=='静态模板'}" th:text="${template.templateType}"></span>
                            <span class="label label-danger" th:if="${template.templateType=='动态模板'}" th:text="${template.templateType}"></span>
                        </td>
                        <td th:text="${template.name}"></td>
                        <td th:text="${template.yuliu1}"></td>
                        <td th:text="${template.total_score}"></td>
                        <td>
                            <span oncontextmenu="return template.list.editTemplateStatus(event,this)" class="label label-primary" th:if="${template.status=='公有' && template.tid==currentTeacherId}">自己公有</span>
                            <span oncontextmenu="return template.list.editTemplateStatus(event,this)" class="label label-default" th:if="${template.status=='私有' && template.tid==currentTeacherId}">自己私有</span>
                            <span oncontextmenu="return template.list.editTemplateStatus(event,this)" class="label label-danger" th:if="${template.tid!=currentTeacherId}">被分享</span>
                            <span oncontextmenu="return template.list.editTemplateStatus(event,this)" class="label label-info" th:if="${template.status=='丢弃' && template.tid==currentTeacherId}">自己丢弃</span>
                        </td>
                        <td th:if="${template.relationTeacher!=null}" th:text="${template.relationTeacher.tname}"></td>
                        <td th:unless="${template.relationTeacher!=null}">无</td>
                        <td>
                            <select class="form-control">
                                <option th:if="${template.shareToTeacher!=null && template.shareToTeacher.size()!=0}" th:each="teacher:${template.shareToTeacher}" th:value="${teacher.id}" th:text="${teacher.tname}" ></option>
                                <option th:unless="${template.shareToTeacher!=null && template.shareToTeacher.size()!=0}">无</option>
                            </select>
                        </td>
                        <td th:text="${template.create_time}"></td>
                        <th:block th:if="${examSymbol!=null || examSymbol!=''}"></th:block>
                        <th:block th:if="${examSymbol==null || examSymbol==''}">
                            <td >
                                <button th:onclick="template.list.edit([[${template.id}]],[[${template.Tid}]],[[${session.loginTeacher.id}]])" style="margin-left: 10px" class="btn-primary"><span class="glyphicon glyphicon-pencil"></span>编辑</button><button style="margin-left: 10px" class="btn-info" th:onclick="template.list.deleteOneList('[[${template.id}]]')"><span class="glyphicon glyphicon-trash"></span>删除</button>
                            </td>
                        </th:block>

                    </tr>
                </th:block>
            </tbody>
        </table>
        <nav th:if="${pageVO.params!=null && pageVO.params.size()!=0}" id="nav" aria-label="Page navigation">
            <ul class="pagination">
                <li th:if="${pageVO.page==1} " class="disabled">
                    <a href="javascript:void(0)" aria-label="Previous">
                        <span aria-hidden="true">&laquo;</span>
                    </a>
                </li>
                <li th:unless="${pageVO.page==1}" >
                    <a th:onclick="|template.list.limitQueryS(${pageVO.page}-1)|" aria-label="Previous">
                        <span aria-hidden="true">&laquo;</span>
                    </a>
                </li>


                <li  th:class="${pageVO.page==index?'active':''}" th:each="index:${#numbers.sequence(pageVO.pageStart,pageVO.pageEnd)}" th:value="${index}">
                    <a th:onclick="|template.list.limitQueryS(${index})|" th:text="${index}"></a>
                </li>


                <li th:if="${pageVO.page==pageVO.realPage}" class="disabled">
                    <a href="javascript:void(0)" aria-label="Next">
                        <span aria-hidden="true">&raquo;</span>
                    </a>
                </li>
                <li th:unless="${pageVO.page==pageVO.realPage}" >
                    <a th:onclick="|template.list.limitQueryS(${pageVO.page}+1)|" aria-label="Next">
                        <span aria-hidden="true">&raquo;</span>
                    </a>
                </li>
            </ul>
        </nav>
    </div>
</body>
</html>